<template>
  <!-- 工单配置 -->
  <div>
    <el-dialog
      title="工单配置"
      :visible.sync="dialogOrder"
      width="45%"
    >
      <div class="form">
        <el-form ref="form" :model="form" label-width="90px" :rules="rules">
          <el-form-item label="补货警戒线:">
            <el-input-number v-model="form.alertValue" style="width: 360px" controls-position="right" :min="1" @change="handleChange" />
          </el-form-item>
        </el-form>
      </div>

      <span slot="footer">
        <div class="footer">
          <el-button style="background-color: #fbf4f0;color: #606266;" @click="dialogOrder = false">取 消</el-button>
          <el-button style="background-color: #ff6726;color:#fff" @click="submit">确 定</el-button>
        </div>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { getPrewarningValue, getPrewarningAuto } from '@/api/lmoperation'

export default {
  name: 'OrderLm',
  components: {
  },
  props: {
  },
  data() {
    return {
      dialogOrder: false,
      form: {
        alertValue: ''
      },
      rules: {

      }
    }
  },
  methods: {
    // 打开弹窗
    async  openOrderDialog() {
      const num = await getPrewarningValue()
      this.form.alertValue = num

      this.dialogOrder = true
    },
    // 关闭弹窗
    offOrderDialog() {
      this.dialogOrder = false
    },
    handleChange(value) {
      this.form.alertValue = value
    },
    // 确定
    async submit() {
      await getPrewarningAuto(this.form)
      this.$message.success('修改成功')
      this.offOrderDialog()
    }
  }
}
</script>

<style scoped lang='scss'>
.form{
  padding-left: 40px;
}
.footer{
  padding-right: 36%;
}
</style>
